package WaiBao;

import java.util.Arrays;

public class ChenLong {
    public static void main(String[] args) {
        String[] name = {"小乐(班长)", "小黑(副班长)", "张小李(学习委员)", "小抄(体育委员)", "小婷", "小值", "小志", "小寻", "小阳", "小锤", "李小彪", "小子",
                "小战", "小博", "小晗", "小兴", "小星", "小愈", "小易", "小甫", "小贺", "小白", "小修", "小婉", "小金", "小颇", "小恬", "小特",
                "小杰", "陈隆(体育委员)"};//考生本人:陈隆(体育委员)
        int[] age = {20, 20, 21, 18, 21, 20, 21, 21, 19,20, 18, 18, 18, 21, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 19, 18, 19};//考生年龄19

        double[] n1 = {68, 88, 85, 60, 88, 89, 78, 59, 60, 70, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 84, 84, 90};
        double[] n2 = {69, 74, 77, 89, 68, 97, 88, 79, 94, 90, 90, 64, 86, 75, 65, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 89, 84, 95};
        double[] n3 = {78, 89, 89, 95, 99, 99, 69, 89, 80, 60, 93, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 78, 94};



        double yue1;//代表每个学生的总分
        double yue2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            yue1 = n1[i] + n2[i] +n3[i];
//            yue2 = (yue1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + yue1);
//            System.out.println(name[i] + "的平均分为:" +yue2);
//        }

        double anpen1 = 0, anpen2 = 0;
        double[] Array = new double[30];
        for (int i = 0; i < 30; i++) {
            anpen1 = n1[i] + n2[i] + n3[i];
            anpen2 = (anpen1 * 1.0) / 3;
            Array[i] =anpen2;
        }

        for (int i = 0; i < Array.length - 1; i++) {
            for (int j = 0; j < Array.length - i - 1; j++) {
                if (Array[j] < Array[j + 1]) {
                    double temp = Array[j];
                    Array[j] = Array[j + 1];
                    Array[j + 1] = temp;
                }
            }
        }
        System.out.println("前十名同学的成绩为:");
        for (int i = 0; i < 10; i++) {
            System.out.println(Array[i]);
        }




        double haha1 = 0, haha2 = 0, haha3 = 0;//计算每门课的平均分
        double f1 = 0, f2 = 0, f3 = 0;//计算每门课标准差
        double v1 = 0, v2 = 0, v3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < n1.length; i++) {
            sum2+=n1[i];
        }
        haha1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+haha1);
        double Sum = 0;
        for (int i = 0; i <n2.length; i++) {
            Sum+=n2[i];
        }
        haha2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+haha2);
        double sum = 0;
        for (int i = 0; i <n3.length; i++) {
            sum+=n3[i];
        }
        haha3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+haha3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < n1.length; i++) {
            c1+= (n1[i] - haha1)*(n1[i] - haha1);
        }
        f1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+f1);

        for (int i = 0; i < n2.length; i++) {
            c2+= (n2[i] - haha2)*(n2[i] - haha2);
        }
        f2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+f2);

        for (int i = 0; i < n3.length; i++) {
            c3+= (n3[i] - haha3)*(n3[i] - haha3);
        }
        f3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+f3);
//
        Arrays.sort(n1);
        Arrays.sort(n2);
        Arrays.sort(n3);
        v1 =( n1[15]+n1[14])*1.0/2;
        v2 =( n2[15]+n2[14])*1.0/2;
        v3 =( n3[15]+n3[14])*1.0/2;
        System.out.println("分析化学的中位数为:"+v1);
        System.out.println("线性代数的中位数为:"+v2);
        System.out.println("有机化学学的中位数为:"+v3);
//



    }
}
